package com.holike.crm.fragment.report.employee;

import android.graphics.Typeface;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.StyleSpan;

import androidx.recyclerview.widget.RecyclerView;

import com.holike.crm.R;
import com.holike.crm.base.BaseFragment;
import com.holike.crm.bean.EmployeeRankingBean;
import com.holike.crm.helper.TextSpanHelper;

import java.util.List;

class DealerOrderHelper extends CommonDealerHelper {

    DealerOrderHelper(BaseFragment<?, ?> fragment, Callback callback) {
        super(fragment, callback);
        doRequest();
    }

    @Override
    void requestUpdate(EmployeeRankingBean.MyRankingBean bean) {
        String source = mContext.getString(R.string.tips_myself_order_amount);
        int start = source.length();
        int end;
        if (bean != null && !TextUtils.isEmpty(bean.myselfOrder)) {
            source += bean.myselfOrder;
        } else {
            source += "-";
        }
        end = source.length();
        source += mContext.getString(R.string.ten_thousand);
        SpannableString ss = new SpannableString(source);
        ss.setSpan(new StyleSpan(Typeface.BOLD), start, end, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
        mDataTextView.setText(ss);
    }

    @Override
    int requestRowId() {
        return R.layout.viewstub_employee_rank_order;
    }

    @Override
    void setAdapter(RecyclerView recyclerView, List<EmployeeRankingBean.RankingDataBean> dataList) {
        recyclerView.setAdapter(new OrderAdapter(mContext, dataList));
    }
}
